<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>提交账单 - TMS</title>
    <link rel="stylesheet" href="/view/frame/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/view/frame/static/css/global.css?v=1.0">
    <link rel="stylesheet" href="/view/tms/static/css/add.css?v=1.0">
    <style>
      body {margin:20px;}
      span.required {color:#f00; font-family:'simsun', '宋体'; margin-right:5px; font-size:15px;}
      .layui-form-label {width:180px;}
      span{line-height: 38px; height: 38px}
      .layui-form-item .layui-input-inline {padding-top: 10px; width:280px;}
    </style>
  </head>
  <body>
    <form class="layui-form" autocomplete="off">
      <div class="layui-row">
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                <label class="layui-form-label">账单号</label>
                <div class="layui-input-block">
                    <span id="billNo" name="billNo"></span>
                </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                <label class="layui-form-label">结算单位</label>
                <div class="layui-input-block">
                    <span id="customerName" name="customerName"></span>
                </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                  <label class="layui-form-label">月份</label>
                <div class="layui-input-block">
                    <span id="billMonth" name="billMonth"></span>
                </div>
              </div>
          </div>
      </div>
      <div class="layui-row">
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                  <label class="layui-form-label">运输单量</label>
                  <div class="layui-input-block">
                      <span id="orderCount" name="orderCount"></span>
                  </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                <label class="layui-form-label">运输柜量</label>
                <div class="layui-input-block">
                    <span id="arkCount" name="arkCount"></span>
                </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                  <label class="layui-form-label">应收运费(元)</label>
                <div class="layui-input-block">
                    <span id="transportCost" name="transportCost"></span>
                </div>
              </div>
          </div>
      </div>
      <div class="layui-row">
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                <label class="layui-form-label">应收异常费(元)</label>
                <div class="layui-input-block">
                    <span id="extraCost" name="extraCost"></span>
                </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                <label class="layui-form-label">应收合计(元)</label>
                <div class="layui-input-block">
                    <span id="totalCost" name="totalCost"></span>
                </div>
              </div>
          </div>
          <div class="layui-col-sm4">
              <div class="layui-form-item">
                  <label class="layui-form-label">已收金额(元)</label>
                <div class="layui-input-block">
                    <span id="receivedCost" name="receivedCost"></span>
                </div>
              </div>
          </div>
      </div>
      <div class="layui-row">
          <div class="layui-col-sm4">
                <div class="layui-form-item layui-form-item--require">
                    <label class="layui-form-label layui-form-item--require" >确认应收金额(元)</label>
                    <div class="layui-input-block">
                        <div class="layui-col-sm11">
                            <input type="text" id="realNeedPay" name="realNeedPay" class="layui-input" maxlength="12" hc-verify="range|decimals2" hc-verify_field="确认应收金额(元)" hc-verify_min="0" hc-verify_max="999999999.99" placeholder="0~999999999.99">
                        </div>
                    </div>
              </div>
          </div>
      </div>
      <div class="layui-row">
          <div class="layui-form-item">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-block">
                <div class="layui-col-sm11">
                    <textarea id="iRemark" name="iRemark" class="layui-textarea"></textarea>
                </div>
            </div>
          </div>
      </div>
      <!-- 未确定内容，勿删 -->
      <!-- <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">提交账单</label>
          <div class="layui-input-inline">
            <input type="text" id="getMoneyDate" placeholder="" class="layui-input">
          </div>
        </div>
      </div> -->
      <br>
      <div class="layui-form-item  button-bar" style="text-align:center">
        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit">提交</button>
        <button class="layui-btn layui-btn-primary btn-cancel" type="button">返回</button>
      </div>
      <hr>
      <div class="layui-row">
          <div style="margin-left:90px">
              <div class="layui-col-sm9">
                  <div class="layui-form-item"> 
                  注：确认应收金额是与客户/车主等确认，需要客户/车主支付给自己的钱，包括已收金额。
                </div>
              </div>
          </div>
        </div>
    </form>
  </body>
  <script charset="utf-8" src="/view/frame/layui/layui.js"></script>
  <script charset="utf-8" src="/view/frame/static/js/jquery.min.js?v=1.0"></script>
  <script charset="utf-8" src="/view/frame/static/js/layui.district.js?v=1.0"></script>
  <script charset="utf-8" src="/view/tms/static/js/tms_tab.js?v=1.0"></script>
  <script charset="utf-8" src="/view/tms/static/js/tms_index.js?v=1219"></script>
  <script charset="utf-8" src="/view/frame/static/js/lang_zh_CN.js?v=1.0"></script>
  
  <script charset="utf-8" src="/view/frame/static/js/errorCodeMap.js"></script>
  <script charset="utf-8" src="/view/frame/static/js/HC.js?v=1.4"></script>
  <script charset="utf-8" src="/view/tms/static/js/validator.js"></script>
  <script charset="utf-8" src="/view/tms/static/js/bizUtil.js"></script>
  
  <script>
  layui.use(['form', 'layer', 'table', 'laydate'], function(){
    var form = layui.form,
        layer = layui.layer,
        table = layui.table,
        laydate = layui.laydate,
        tmsTab = layui.tms_tab,
        $ = layui.jquery;

    laydate.render({
      elem: '#getMoneyDate' //收款日期
      ,format: 'yyyy-MM-dd hh:mm:ss'
    });

    $("#realNeedPay").on("blur",function(){
      var $realNeedPay = $("#realNeedPay").val();
      var $receivedCost = $('span[name="receivedCost"]').html();
      var $needPut = ($realNeedPay - $receivedCost);
      $("#NeedPay").html($needPut);
    })

    var $id = $.trim(getUrlParam('customerId'));
    var billMonth;

     //获取数据
    $.get('/ucenter/general/finance/receivedBills/' + $id + '.shtml', function(d){
      var $code = d.code,
          $msg = d.msg,
          $objects = d.objects;
          billMonth = $objects.billMonth == null ? "" : $objects.billMonth ;
          $('span[name="billNo"]').html($objects.billNo);
          $('span[name="customerName"]').html($objects.customerName);
          $('span[name="billMonth"]').html(billMonth == "" ? "" : new Date($objects.billMonth).format('yyyy-MM') );
          $('span[name="orderCount"]').html($objects.orderCount);
          $('span[name="arkCount"]').html($objects.arkCount);
          $('span[name="transportCost"]').html($objects.transportCost);
          $('span[name="extraCost"]').html($objects.extraCost);
          $('span[name="totalCost"]').html($objects.totalCost);
          $('span[name="receivedCost"]').html($objects.receivedCost);
    }, 'json');

    //监听提交
    form.on('submit(submit)', function(data){
    var $billNo = $.trim($('span[name="billNo"]').html()),
        $customerName = $.trim($('span[name="customerName"]').html()),
        $billMonth = billMonth,
        $orderCount = $.trim($('span[name="orderCount"]').html()),
        $arkCount = $.trim($('span[name="arkCount"]').html()),
        $transportCost = $.trim( $('span[name="transportCost"]').html()),
        $extraCost = $.trim($('span[name="extraCost"]').html()),
        $totalCost = $.trim($('span[name="totalCost"]').html()),
        $realNeedPay = $.trim(data.field.realNeedPay),
        $iRemark = $.trim(data.field.iRemark),
        $receivedCost = $.trim($('span[name="receivedCost"]').html());
    var $saveData = {
          receivedBillsNo:$billNo,
          customerName:$customerName,
          receivedBillsId:$id,
          billMonth:$billMonth,
          myOrderCount:$orderCount,
          myArkCount:$arkCount,
          myTransportCost:$transportCost,
          myExtraCost:$extraCost,
          myTotalCost:$totalCost,
          realNeedPay:$realNeedPay,
          iRemark:$iRemark,
          receiveCost:$receivedCost,
    }
    // console.log($saveData);
    roleStatus($saveData);
    return false;
    });

    function roleStatus($ids){
      console.log($ids);
      var $saveData = $ids;
       $.ajax({
        type:'POST', 
        url:'/ucenter/general/finance/receivedBills/insertVerifyBills.shtml', 
        dataType:"json",      
        contentType:"application/json",               
        data:JSON.stringify($saveData),
        success:function(d){
          var $code = d.code,
              $msg = d.msg,
              $objects = d.objects;
          if($code === 'SUCCESS'){
            // tmsTab.del($(window.parent.document).find('.layui-tab-title li.layui-this').attr('lay-id'));
            layer.msg('操作成功！');
          }else{
            parent.layer.alert('操作失败！');
          }
        }
      });
    }

    $(".btn-cancel").on("click",function(){
      tmsTab.del($(window.parent.document).find('.layui-tab-title li.layui-this').attr('lay-id'));
    });
  });
  </script>
</html>